﻿using T4UtilityBelt.Writers;

namespace T4UtilityBelt.UxDesigns.Controls.Renderers.Android
{
    public class ButtonRenderer : ControlRenderer<ButtonControl, IButtonRenderer>, IButtonRenderer
    {

        protected override void OnRenderUiXmlBegin(ButtonControl control, CodeWriter writer)
        {
            writer.WriteBeginTag("Button");
            RenderControlAttributes(control, writer);
            writer.WriteAttribute("android:text", control.Text);
            writer.AddBinding("Click", control.Click);
            writer.RenderBindingsAttribute();
            //writer.WriteAttributeFormat("Command", @"{{Binding {0}}}", control.CommandName);
            writer.WriteFullEnd();
        }

        protected override void OnRenderUiXmlContent(ButtonControl control, CodeWriter writer)
        {
            control.Controls.RenderUiXml(writer);
        }

        protected override void OnRenderUiXmlEnd(ButtonControl control, CodeWriter writer)
        {
            
        }

        protected override void OnRenderUiCode(ButtonControl control, CodeWriter writer)
        {
//            writer.WriteFormatLine(
//@"      public ICommand {0}Command
//        {{
//            get
//            {{
//                return new MvxRelayCommand(Execute{0});
//            }}
//        }}
// 
//        public Partial void Execute{0}();
//",
//control.CommandName
//);

        }
    }
}